package sybl.wb.com.demo.utils;

import com.android.volley.Request;
import com.android.volley.RequestQueue;
import com.android.volley.toolbox.Volley;

import sybl.wb.com.demo.BaseApp;

/**
 * Created by wbcomputer on 2015/10/16.
 */
public class VolleyHelper {
    private static VolleyHelper volleyHelper;
    private RequestQueue queue;

    private VolleyHelper() {

    }

    public static VolleyHelper getInstance() {
        return volleyHelper;
    }

    public RequestQueue getQueue() {
        if (queue == null) {
            queue = Volley.newRequestQueue(BaseApp.getInstance());
        }

        return queue;
    }

    public void addRequest(Request<?> request,Object tag){
        if (getQueue()!=null){
            request.setShouldCache(false);
            request.setTag(tag);
            getQueue().add(request);
        }
    }

}
